---
layout: demo
title: 微信接口测试
description: WeixinJSBridge对象的部分接口测试
category: demo
custom_css: |
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"  />
  <meta name="format-detection" content="telephone=no">
  <style>
  img{max-width:100%;}
  </style>
---
<p><script>document.write(navigator.userAgent)</script></p>
<p>当前网络链接：<strong id="network"></strong></p>
<p>点击图片浏览更多大图</p>
<p id="imagePreview">
  <img src="https://photo.res.meizu.com/static/cn/pictorial/paris/paris-1/paris-1-1-nomal_f819779.jpg" alt="巴黎">
</p>
<p>
</p>
<ul>
  <li><a href="weixin://dl/officialaccounts">公众号 weixin://dl/officialaccounts</a></li>
  <li><a href="http://weixin.qq.com/r/NUPt9arEz-ewre6W9xYn">猫哥学前班（二维码转成的链接）</a></li>
  <li><a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzA5NDM2MDU0Nw==&scene=124#wechat_redirect">猫哥学前班（历史消息链接）</a></li>
</ul>


<script>
var result = '',
    networkMap = {
      "network_type:wifi": "wifi网络",
      "network_type:edge": "非wifi,包含3G/2G",
      "network_type:fail": "网络断开连接",
      "network_type:wwan": "2G或者3G",
      "network_type:not_allow": "无系统权限"
    },
    imgList = [
      'https://photo.res.meizu.com/static/cn/pictorial/paris/paris-1/paris-1-1-nomal_f819779.jpg',
      'https://photo.res.meizu.com/static/cn/pictorial/paris/paris-1/paris-1-4-nomal_0749e0e.jpg',
      'https://photo.res.meizu.com/static/cn/pictorial/paris/paris-1/paris-1-7-nomal_550f9a7.jpg',
      'https://photo.res.meizu.com/static/cn/pictorial/toyko/toyko-2/toyko-2-5-nomal_00f0920.jpg'
    ]

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
  document.getElementById('imagePreview').onclick = function(){
    WeixinJSBridge.invoke('imagePreview',{ 'current':imgList[0], 'urls':imgList} );   
  }
  /*
  var keys = [];
  for(i in WeixinJSBridge){
    keys.push(i);
  }
  keys.sort().forEach(function(el,n){
    document.writeln(el +":" +WeixinJSBridge[el] + '<br />');
  })
  */
  //隐藏右上角分享按钮
  //WeixinJSBridge.call('hideOptionMenu');
  //隐藏底部状态栏
  WeixinJSBridge.call('hideToolbar');

  WeixinJSBridge.invoke('getNetworkType',{},
    function(e){
      document.getElementById('network').innerHTML = networkMap[e.err_msg];
  });

});


</script>
